package studychinese.adapters;

import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.hschinese.pronunciation.R;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;


/**
 * Created by lenovo on 2017/4/9.
 */
public class HopeRanContentAdapter extends AppAdapter {
    private int mPosstion = -2;

    public HopeRanContentAdapter(List list, Context context) {
        super(list, context);

    }

    @Override
    public View createView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        if (convertView == null) {
            convertView = View.inflate(context, R.layout.item_lv_rank_content, null);
            viewHolder = new ViewHolder(convertView);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        if(position==0){
            viewHolder.tvItemRankContetnnumber.setText("级别");
            viewHolder.tvItemRankShuoming.setText("级别描述");
        }else {
            viewHolder.tvItemRankContetnnumber.setText(position-1+"级");
            viewHolder.tvItemRankShuoming.setText("能用汉语规范的交流");
        }
       if(mPosstion==position-1){
           viewHolder.ll_lv_rank.setBackgroundResource(R.mipmap.inputzhijiao);

       }else {
           viewHolder.ll_lv_rank.setBackgroundColor(Color.TRANSPARENT);
       }
        return convertView;
    }

    public void setBk(int i) {
        mPosstion=i;
    }


    static class ViewHolder {
        @Bind(R.id.tv_item_rank_contetnnumber)
        TextView tvItemRankContetnnumber;
        @Bind(R.id.tv_item_rank_shuoming)
        TextView tvItemRankShuoming;
        @Bind(R.id.ll_lv_rank)
        LinearLayout ll_lv_rank;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
